1. Field of the Invention
This invention relates generally to a computer graphics system, and more particularly, to a method and apparatus for quickly copying data from one window to another window in frame buffer memory.
2. Description of Related Art
Graphic capabilities are now common in a variety of applications for personal computers, including three-dimensional (3D) games, multimedia communications and computer-aided design applications (CAD), which perform many graphic functions, including 3D animation, sophisticated shading algorithms, transparency and alpha-blending, live video windows, stereo 3D windows, etc. To perform the desired graphic functions with some realism, the computer system must be capable of performing more sophisticated functions in less time. This is particularly true for graphics animation. The computer system must be able to draw complicated graphical figures and fill them while performing complicated 2D and 3D functions, such as patterning, depth cueing, light source modeling, alpha blending, texture mapping, anti-aliasing, hidden surface removal, stenciling, panning and zooming, as well as depth and color interpolation, among other functions. The computer system must also draw the graphical figures at a much greater speed while manipulating the pixel data being refreshed to a display output device.
A typical computer system has a central processing unit (CPU) with a main memory and a graphics display subsystem with its own memory subsystem. Part of this graphics memory subsystem is a frame buffer that stores data that is to be displayed on a display output device such as a monitor, TV or flat panel display. A display controller reads the data in the frame buffer line-by-line, converts the data into an analog video signal using a digital-to-analog converter (DAC), and transmits the analog video signal to the display output device. This process is generally known as xe2x80x9crefreshingxe2x80x9d the display output device. The entire contents of the frame buffer need to be transferred to the display output device continuously for the display to be visible. In the case of a monitor, this is typically at least 60 times per second, so that the viewer sees what appears to be a constant, unflickering picture. The line-by-line refreshing generally begins at a window in the frame buffer corresponding to the upper left-hand corner of the display screen and continuing to the lower right-hand corner. The refreshing operation returns from the lower right-hand corner to the upper left-hand corner during a vertical retrace period.
Typically, the frame buffer is constructed of some form of dynamic random access memory (DRAM) such as, asynchronous DRAM, synchronous DRAM (xe2x80x9cSDRAMxe2x80x9d), double-data-rate synchronous DRAM (xe2x80x9cDDRDRAMxe2x80x9d), synchronous graphic DRAM (xe2x80x9cSGRAMxe2x80x9d), or Rambus direct DRAM (xe2x80x9cRDRAMxe2x80x9d).
To animate objects on the display output device coupled to the frame buffer; animation software/hardware renders a series of frames with slight picture changes in each frame. To provide smooth animation, at least 15 to 30 new frames should be displayed each second. As the picture in one frame changes to the picture in the next frame, continuous motion is presented. To accomplish this, the frame buffer must be continually updated.
The ability of the frame buffer to both receive information and transfer that information to an output display simultaneously causes certain difficulties. If the animation software/hardware writes to frame buffer memory while the display controller is scanning the image in the frame buffer memory to a display, then the display may present information from more than one animation frame at time. This problem is referred to as frame tear. Frame tears are only important where motion from one frame to the next causes the elements presented on the display to be obviously distorted. When this occurs, the distortion caused may be extremely disconcerting to the viewer.
To eliminate frame tears, certain computer systems utilize a system referred to as double buffering. Double buffering allows for one image to be rendered while another is being displayed. Double buffering is often achieved by rendering the non-visible image in main memory and then quickly copying the image data to the frame buffer for display on the display output device. A better alternative is a double buffered system which provides two regions of memory in the frame buffer wherein each region of memory may furnish pixel information to the display controller and ultimately the display output device.
A first region of memory known as a front visible buffer provides a first animation frame to the display output device, and no changes are made in that memory region while it provides information to the display output device. While the front buffer is displayed on the display output device, animation software/hardware renders the next animation frame in the second region of memory known as a back non-visible buffer. When the animation software/hardware completes the next animation frame the display is changed such that the back buffer becomes the displayed frame and the front buffer becomes the xe2x80x9cworkxe2x80x9d region in which the animation software renders the next animation frame. The change occurs during the vertical retrace period to further avoid causing frame tears. In this manner, no pixel information is ever written to the region of memory that is visible on the display output device.
The process of making the back buffer visible may take many forms. The most straight-forward way is to copy data between the back and front buffers. Fundamentally, this is handled with a stream of read pixel and write pixel operations. Since copying pixels from one region to another is very common, a special graphics function called a bit block transfer (bitBlt) has been developed. The bitBlt command is found in most graphics controller implementations and is often implemented directly in the graphics hardware for highest speed. The command is used to copy an array of pixels from a rectangular window in memory, the source window, to a destination window. This command is also useful to move data from a back buffer located in main memory instead of frame buffer memory. Although, the bitBlt command is well known and widely supported, it has a disadvantage of being slow.
Other methods of making the back buffer visible are available through graphics application programming interfaces (APIs), such as OpenGL, Direct3D and PHIGS (Programmer""s Hierarchical Interactive Graphics System). For example, OpenGL provides a command called glxSwapBuffer that, depending upon the implementation, may cause hardware to simply swap what buffer is the front and back buffer without actually copying data. This method, limited to double buffers implemented as two regions of the frame buffer, is very fast and is often referred to as xe2x80x9cfast buffer-swap.xe2x80x9d However, some applications, especially Windows NT applications, prefer that the contents of the back buffer remain intact, and thus prefer that the swap be implemented as a pixel data copy. Accordingly, a faster method of copying data is desired.
According to a preferred embodiment, the invention provides a method and apparatus for efficiently copying pixels from different portions of a frame buffer. The invention may be viewed as a display controller for copying a pixel region. The display controller may comprise a frame buffer configured into n interleaved banks where n is greater than one, each bank having a width of m contiguous pixel locations where m is greater than zero; n memory controllers, each memory controller coupled to a bank for reading and writing pixels, each memory controller having a pair of buffer pointers for holding first and second address offsets; and a pixel addressing means coupled to the n memory controllers for generating pixel addresses defining the pixel region with respect to a first address offset, the pixel region contained within the frame buffer, and for distributing the addresses to memory controllers according to the pixel locations each memory controller is coupled thereto, wherein the addresses distributed to the memory controllers cause each memory controller to read pixels within its bank according to the addresses and the first address offset, and write the pixels within its bank according to the addresses and the second address offset.
The invention may also be viewed as a method of copying a pixel region. The method may be broadly conceptualized by the following steps: providing a frame buffer configured into n interleaved banks where n is greater than one, each bank having a width of m contiguous pixel locations where m is greater than zero; providing n memory controllers, each memory controller coupled to a bank, and each memory controller having a pair of buffer pointers for holding address offsets; generating pixel addresses defining a pixel region with respect to a first offset, the pixel region contained within the frame buffer; routing the pixel addresses to the memory controllers according to the pixel locations each memory controller is coupled thereto; and each memory controller, reading pixels within its bank according to the pixel addresses and a first offset and writing the pixels within its bank according to the pixel addresses and a second offset.
Each memory controller may further include an additional pair of buffer pointers for holding address offsets and the method may further comprise: each memory controller, reading pixels within its bank according to the pixel addresses and a third offset and writing the pixels within its bank according to the pixel addresses and a fourth offset. The frame buffer may be configured into a first and second buffer, wherein the pixels are read from the first buffer and written to the second buffer.
Other features and advantages of the invention will become apparent to one of ordinary skill in the art upon examination of the following detailed description of illustrative embodiments in conjunction with the accompanying drawings. It is intended that all such features and advantages be included herein within the scope of the invention and protected by the claims.